//
//  YBMeetingReleaseViewController.m
//  GongXinDangJian
//
//  Created by apple on 17/12/8.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "YBMeetingReleaseViewController.h"
#import "YBNormalWaterLayoutView.h"
#import "YBNewChoosePeopleViewController.h"
#import "PlaceholderTextView.h"
#import "ZJSIPotoView.h"
#import "ZLPhotoActionSheet.h"
#import "STPhotoBroswer.h"
#import "YBPeopleInfoModel.h"
#import "LCustomAlertView.h"
#import "ZJRBTextFliedView.h"
#import "MyICRemarkView.h"
#import "LPCostomLabelAndTextFieldAndImageView.h"
#import "YBSignInReturnContentViewController.h"
#import "ZJWebViewController.h"
#import "YBReleaseMeetingPreViewController.h"
#import "ZJSqlit.h"

@interface YBMeetingReleaseViewController ()<YBNewChoosePeopleViewControllerDelegate , UITextFieldDelegate , LPChooseYearAndMonthAndDayAndHourAndMinuteDelegate , ZJSIPotoViewDelegate , LCustomAlertDelegate , YBNormalWaterLayoutViewDelegate , LPCostomLabelAndTextFieldAndImageViewDelegate , YBSignInReturnContentViewControllerDelegate>
{
    NSInteger _index;/**< 标记图片数组的长度 */
    NSInteger _deleImageIndex;/**< 删除图片的下标 */
}
/**  back  */
@property (strong, nonatomic) UIScrollView  *backScrollView;

@property (nonatomic , strong) ZJSqlit * mySqlite;

@property (nonatomic , strong) YBNormalWaterLayoutView * selectView;

@property (nonatomic , strong) NSArray * dataArray;

@property (nonatomic , strong) UITextField * currentSelectTextField;

@property (nonatomic , strong) LPChooseYearAndMonthAndDayAndHourAndMinuteView * pickTime;

@property (nonatomic , strong) ZJSIPotoView * potoView;
/** 图片数组 */
@property (nonatomic, strong) NSMutableArray *imageArray;

@property (nonatomic , strong) JCAlertView * jcAlertView;

@property (nonatomic , assign) NSInteger currentDeleteIndex;

/** 会议活动名称 */
@property (nonatomic, strong) ZJRBTextFliedView *nameTextField;
/** 会议内容 */
@property (nonatomic, strong) MyICRemarkView * contentTextView;
/** 联系人 */
@property (nonatomic, strong) ZJRBTextFliedView *contactTextField;
/** 联系电话 */
@property (nonatomic, strong) ZJRBTextFliedView *phoneTextField;
/** 发布单位 */
@property (nonatomic, strong) ZJRBTextFliedView *deptTextField;
/** 会议时间 */
@property (nonatomic, strong) LPCostomLabelAndTextFieldAndImageView *meetingTimeTextField;
/** 会议地址 */
@property (nonatomic, strong) ZJRBTextFliedView *addressTextField;
/** 发布时间 */
@property (nonatomic, strong) LPCostomLabelAndTextFieldAndImageView * releaseTimeTextField;
/** 截止时间 */
@property (nonatomic, strong) LPCostomLabelAndTextFieldAndImageView * endTimeTextField;

@property (nonatomic , strong) UIView * returnButtonView;
/** 添加回执 */
@property (nonatomic , strong) UIButton * addReturnButton;
/** 预览回执 */
@property (nonatomic , strong) UIButton * previewReturnButton;

/** 预览 */
@property (nonatomic , strong) UIButton * previewMeetingButton;
/** 发布 */
@property (nonatomic , strong) UIButton * releaseMeetingButton;

@property (nonatomic , strong) NSString * ACTID;

@property (nonatomic , strong) NSArray * selectReturnArray;

@property (nonatomic , strong) NSArray * diyReturnArray;

@end

@implementation YBMeetingReleaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.dataArray = @[];
    self.currentSelectTextField = nil;
    self.currentDeleteIndex = 0;
    self.selectReturnArray = @[];
    self.diyReturnArray = @[];
    self.titlelabel.text = @"会议发布";
    self.ACTID = [[ToolClass createUUIDString] stringByReplacingOccurrencesOfString:@"-" withString:@""];
    [self ybInitUserInterface];
}

-(void)ybInitUserInterface{
    [self.view addSubview:self.backScrollView];
    [self.backScrollView addSubview:self.selectView];
    [self.backScrollView addSubview:self.nameTextField];
    [self.backScrollView addSubview:self.contentTextView];
    [self.backScrollView addSubview:self.contactTextField];
    [self.backScrollView addSubview:self.phoneTextField];
    [self.backScrollView addSubview:self.deptTextField];
    [self.backScrollView addSubview:self.meetingTimeTextField];
    [self.backScrollView addSubview:self.addressTextField];
    [self.backScrollView addSubview:self.releaseTimeTextField];
    [self.backScrollView addSubview:self.endTimeTextField];
    
    self.returnButtonView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith] , ItemHeight * 160)];
    self.returnButtonView.backgroundColor = [UIColor whiteColor];
    [self.backScrollView addSubview:self.returnButtonView];
    
    UILabel * returnTitleLabel = [ToolClass creatLabelWithFrame:CGRectMake(ItemWidth * 30, 0, [UIScreen zj_screenWith] - ItemWidth * 60, ItemHeight * 40) font:16 textColor:[UIColor textBlackColor] text:@"选择报名回执所需内容(可多选):"];
    [self.returnButtonView addSubview:returnTitleLabel];
    [self.returnButtonView addSubview:self.addReturnButton];
    [self.returnButtonView addSubview:self.previewReturnButton];
    
    [self.backScrollView addSubview:self.potoView];
    
    UIView * bottomButtonView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], ItemHeight * 100)];
    bottomButtonView.backgroundColor = [UIColor whiteColor];
    [self.backScrollView addSubview:bottomButtonView];
    [bottomButtonView addSubview:self.previewMeetingButton];
    [bottomButtonView addSubview:self.releaseMeetingButton];
    
    
    self.nameTextField.sd_layout
    .topSpaceToView(self.selectView, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.nameTextField.height);
    
    self.contentTextView.sd_layout
    .topSpaceToView(self.nameTextField, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.contentTextView.height);
    
    self.contactTextField.sd_layout
    .topSpaceToView(self.contentTextView, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.contactTextField.height);
    
    self.phoneTextField.sd_layout
    .topSpaceToView(self.contactTextField, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.phoneTextField.height);
    
    self.deptTextField.sd_layout
    .topSpaceToView(self.phoneTextField, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.deptTextField.height);
    
    self.meetingTimeTextField.sd_layout
    .topSpaceToView(self.deptTextField, ItemHeight * 20)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.meetingTimeTextField.height);
    
    self.addressTextField.sd_layout
    .topSpaceToView(self.meetingTimeTextField, -ItemHeight * 20)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.addressTextField.height);
    
    self.releaseTimeTextField.sd_layout
    .topSpaceToView(self.addressTextField, ItemHeight * 20)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.releaseTimeTextField.height);
    
    self.endTimeTextField.sd_layout
    .topSpaceToView(self.releaseTimeTextField, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.endTimeTextField.height);
    
    self.returnButtonView.sd_layout
    .topSpaceToView(self.endTimeTextField, 0)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.returnButtonView.height);
    
    self.potoView.sd_layout
    .topSpaceToView(self.returnButtonView, ItemHeight * 32)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(self.potoView.height);
    
    bottomButtonView.sd_layout
    .topSpaceToView(self.potoView, ItemHeight * 50)
    .leftSpaceToView(self.backScrollView, 0)
    .rightSpaceToView(self.backScrollView, 0)
    .heightIs(bottomButtonView.height);
//
    [self.backScrollView setupAutoContentSizeWithBottomView:bottomButtonView bottomMargin:ItemHeight * 50];
}


- (void)senderNetWorking{
    NetWorkUpLoadModel *loadModel = [NetWorkUpLoadModel new];
    loadModel.UPLOAD_FILES = self.imageArray;
    loadModel.ACT_ID = self.ACTID;
    loadModel.TITLE = self.nameTextField.textField.text;
    loadModel.CONTENT = self.contentTextView.textView.text;
    loadModel.CONTACT_NAME = self.contactTextField.textField.text;
    loadModel.CONTACT_MOBILE = self.phoneTextField.textField.text;
    loadModel.PUBLISH_UNIT = self.deptTextField.textField.text;
    loadModel.HY_START_TIME = self.meetingTimeTextField.secondTextField.text;
    loadModel.ADDRESS = self.addressTextField.textField.text;
    loadModel.START_TIME = self.releaseTimeTextField.secondTextField.text;
    loadModel.END_TIME = self.endTimeTextField.secondTextField.text;
    loadModel.CREATE_ACCOUNT_ID = [ToolClass returnNoNullStringWithString:ZJUSERINFORMODEL.ORG_ACCOUNT.ID];
    NSMutableArray * tempArray = [NSMutableArray array];
    for (YBPeopleInfoModel * model in self.selectView.dataArray) {
        NSMutableDictionary * tempDic = [NSMutableDictionary dictionary];
        [tempDic setValue:model.ACCOUNT_ID forKey:@"ACCOUNT_ID"];
        [tempDic setValue:model.NAME forKey:@"PARTYMEMBER_NAME"];
        [tempDic setValue:model.F_DEPT_NAME forKey:@"PARTYMEMBER_DEPT_NAME"];
        [tempDic setValue:model.FID forKey:@"PARTYMEMBER_DEPT_ID"];
        [tempArray addObject:[tempDic copy]];
    }
    loadModel.PARTYMEMBERS = [ToolClass getjsonStringFromArray:[tempArray copy]];
    [YJProgressHUD showMessage:@"发布中..." duration:10 view:[UIApplication sharedApplication].keyWindow];
    [NetWorkingManager uploadingWithXMLString:@"miit.action.HyAction[addHy]" Parameter:loadModel Success:^(id object) {
        [YJProgressHUD hide];
        if ([object[@"STATE"] isEqualToString:@"20000"]) {
            [YJProgressHUD showSuccess:@"发布成功" inview:self.view];
            
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [self.navigationController popViewControllerAnimated:YES];
            });
            
        }else{
            [YJProgressHUD showSuccess:@"发布失败" inview:self.view];
        }
    } Fail:^(id object) {
        [YJProgressHUD hide];
        [YJProgressHUD showSuccess:@"网络错误" inview:self.view];
    }];
}


-(void)option_selectButton:(UIButton *)sender{
    [self.contentTextView endEditing:YES];
    YBNewChoosePeopleViewController * vc = [[YBNewChoosePeopleViewController alloc]init];
    vc.delegate = self;
    [self.navigationController pushViewController:vc animated:YES];
    
}

-(void)option_addReturnButton:(UIButton *)sender{
    YBSignInReturnContentViewController * vc = [[YBSignInReturnContentViewController alloc]init];
    vc.delegate = self;
    vc.ACTID = self.ACTID;
    vc.currentSelectArray = [self.selectReturnArray mutableCopy];
    vc.currentDiyArray = [self.diyReturnArray mutableCopy];
    [self.navigationController pushViewController:vc animated:YES];
}


-(void)option_previewReturnButton:(UIButton *)sender{
    ZJWebViewController *vc = [ZJWebViewController new];
    NSString *urlString = [NSString stringWithFormat:@"%@/miit/view/previewTable.html?ACTID=%@",HTMLURL,self.ACTID];
    vc.titleString = @"回执预览";
    vc.urlString = urlString;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)option_previewMeetingButton:(UIButton *)sender{
    if (self.selectView.dataArray.count == 0) {
        [YJProgressHUD showSuccess:@"请选择发布对象" inview:self.view];
        return;
    }
    if (self.nameTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议活动名称" inview:self.view];
        return;
    }
    if (self.contentTextView.textView.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议内容" inview:self.view];
        return;
    }
    if (self.contactTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入联系人" inview:self.view];
        return;
    }
    if (self.phoneTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入联系电话" inview:self.view];
        return;
    }
    if (self.deptTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入发布单位" inview:self.view];
        return;
    }
    if (self.nameTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议活动名称" inview:self.view];
        return;
    }
    if (self.meetingTimeTextField.secondTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请选择会议时间" inview:self.view];
        return;
    }
    if (self.addressTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议地址" inview:self.view];
        return;
    }
    if (self.releaseTimeTextField.secondTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请选择发布时间" inview:self.view];
        return;
    }
    if (self.endTimeTextField.secondTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请选择截止时间" inview:self.view];
        return;
    }
    
    NSTimeInterval meetingTime = [[NSDateFormatter dateHourAndMintueWithString:self.meetingTimeTextField.secondTextField.text] timeIntervalSince1970];
    NSTimeInterval releaseTime = [[NSDateFormatter dateHourAndMintueWithString:self.releaseTimeTextField.secondTextField.text] timeIntervalSince1970];
    NSTimeInterval endTime = [[NSDateFormatter dateHourAndMintueWithString:self.endTimeTextField.secondTextField.text] timeIntervalSince1970];
    if (endTime > meetingTime) {
        [YJProgressHUD showSuccess:@"会议时间必须大于截止时间" inview:self.view];
        return;
    }
    if (releaseTime > endTime) {
        [YJProgressHUD showSuccess:@"截止时间必须大于发布时间" inview:self.view];
        return;
    }
    YBReleaseMeetingPreViewController * vc = [[YBReleaseMeetingPreViewController alloc]init];
    vc.peopleArray = self.selectView.dataArray;
    NetWorkUpLoadModel *loadModel = [NetWorkUpLoadModel new];
    loadModel.UPLOAD_FILES = self.imageArray;
    loadModel.ACT_ID = self.ACTID;
    loadModel.TITLE = self.nameTextField.textField.text;
    loadModel.CONTENT = self.contentTextView.textView.text;
    loadModel.CONTACT_NAME = self.contactTextField.textField.text;
    loadModel.CONTACT_MOBILE = self.phoneTextField.textField.text;
    loadModel.PUBLISH_UNIT = self.deptTextField.textField.text;
    loadModel.HY_START_TIME = self.meetingTimeTextField.secondTextField.text;
    loadModel.ADDRESS = self.addressTextField.textField.text;
    loadModel.START_TIME = self.releaseTimeTextField.secondTextField.text;
    loadModel.END_TIME = self.endTimeTextField.secondTextField.text;
    loadModel.CREATE_ACCOUNT_ID = [ToolClass returnNoNullStringWithString:ZJUSERINFORMODEL.ORG_ACCOUNT.ID];
    vc.model = loadModel;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)option_releaseMeetingButton:(UIButton *)sender{
    if (self.selectView.dataArray.count == 0) {
        [YJProgressHUD showSuccess:@"请选择发布对象" inview:self.view];
        return;
    }
    if (self.nameTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议活动名称" inview:self.view];
        return;
    }
    if (self.contentTextView.textView.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议内容" inview:self.view];
        return;
    }
    if (self.contactTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入联系人" inview:self.view];
        return;
    }
    if (self.phoneTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入联系电话" inview:self.view];
        return;
    }
    if (self.deptTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入发布单位" inview:self.view];
        return;
    }
    if (self.nameTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议活动名称" inview:self.view];
        return;
    }
    if (self.meetingTimeTextField.secondTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请选择会议时间" inview:self.view];
        return;
    }
    if (self.addressTextField.textField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请输入会议地址" inview:self.view];
        return;
    }
    if (self.releaseTimeTextField.secondTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请选择发布时间" inview:self.view];
        return;
    }
    if (self.endTimeTextField.secondTextField.text.length == 0) {
        [YJProgressHUD showSuccess:@"请选择截止时间" inview:self.view];
        return;
    }
    if (self.selectReturnArray.count == 0) {
        [YJProgressHUD showSuccess:@"请添加回执内容" inview:self.view];
        return;
    }
    
    NSTimeInterval meetingTime = [[NSDateFormatter dateHourAndMintueWithString:self.meetingTimeTextField.secondTextField.text] timeIntervalSince1970];
    NSTimeInterval releaseTime = [[NSDateFormatter dateHourAndMintueWithString:self.releaseTimeTextField.secondTextField.text] timeIntervalSince1970];
    NSTimeInterval endTime = [[NSDateFormatter dateHourAndMintueWithString:self.endTimeTextField.secondTextField.text] timeIntervalSince1970];
    if (endTime > meetingTime) {
        [YJProgressHUD showSuccess:@"会议时间必须大于截止时间" inview:self.view];
        return;
    }
    if (releaseTime > endTime) {
        [YJProgressHUD showSuccess:@"截止时间必须大于发布时间" inview:self.view];
        return;
    }
    [self senderNetWorking];
}


-(void)didCreateReturnCardWithSelectArray:(NSArray *)selectArray diyArray:(NSArray *)diyArray
{
    self.selectReturnArray = selectArray;
    self.diyReturnArray = diyArray;
}



-(void)didClickDeleteButtonWithIndex:(NSInteger)index{
    self.currentDeleteIndex = index;
    YBPeopleInfoModel * tempModel = self.dataArray[index];
    LCustomAlertView *alert = [[LCustomAlertView alloc] initWithFrame:self.view.bounds alertMessage:[NSString stringWithFormat:@"是否删除 %@-%@" , [ToolClass returnNoNullStringWithString:tempModel.F_DEPT_NAME] , [ToolClass returnNoNullStringWithString:tempModel.NAME]] titlesArray:@[@"取消",@"确定"]];
    alert.delegate = self;
    self.jcAlertView = [[JCAlertView alloc]initWithCustomView:alert dismissWhenTouchedBackground:YES];
    [self.jcAlertView show];
}


#pragma mark - LCustomAlertDelegate
- (void)lCustomAlertWithView:(LCustomAlertView *)view index:(NSInteger)index{
    if (index == 1) {
        /**  确认  */
        NSMutableArray * tempArray = [self.dataArray mutableCopy];
        [tempArray removeObjectAtIndex:self.currentDeleteIndex];
        self.dataArray = [tempArray copy];
        [self.selectView deleteItemAtIndex:self.currentDeleteIndex];
    }
    [self.jcAlertView dismissWithCompletion:nil];
}

- (void)LPCostomLabelAndTextFieldAndImageWith:(LPCostomLabelAndTextFieldAndImageView *)view click:(BOOL)click{
    //时间选择按钮
    self.currentSelectTextField = view.secondTextField;
    [self.view endEditing:YES];
    [self.pickTime showCurrentTime];
    
}



-(void)ybClickEnsureButtonWithCurrentSelectArray:(NSArray *)currentSelectArray
{
    NSMutableArray * tempArray = [NSMutableArray array];
    for (YBPeopleInfoModel * model in self.dataArray) {
        [tempArray addObject:model.ACCOUNT_ID];
    }
    NSMutableArray * addArray = [self.dataArray mutableCopy];
    for (YBPeopleInfoModel * tempModel in currentSelectArray) {
        if (![tempArray containsObject:tempModel.ACCOUNT_ID]) {
            [addArray addObject:tempModel];
        }
    }
    self.dataArray = [addArray copy];
    self.selectView.dataArray = [addArray copy];
}


- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return YES;
}



- (void)ChooseYearAndMonthAndDayAndHourAndMinuteWithTitle:(NSString * )string{
    if (self.currentSelectTextField) {
        self.currentSelectTextField.text = string;
    }
    //选择年月日返回代理方法
}


#pragma mark - ZJSIPotoViewDelegate(图片加好) 协议方法
- (void)ZJSIPotoViewDelegate_addPotoClick{
    [self.view endEditing:YES];
    if (self.imageArray.count == 9) {
        [YJProgressHUD showMessage:@"最多选择9张图片" inView:self.view];
    }
    else{
        _index = self.imageArray.count;
        //图片多选模块
        ZLPhotoActionSheet *actionSheet = [[ZLPhotoActionSheet alloc] init];
        //设置最大选择数量
        actionSheet.maxSelectCount = 9 - self.imageArray.count;
        //设置预览图最大数目
        actionSheet.maxPreviewCount = 20;
        __weak typeof(self) weakSelf = self;
        [actionSheet showWithSender:self animate:YES lastSelectPhotoModels:nil completion:^(NSArray<UIImage *> * _Nonnull selectPhotos, NSArray<ZLSelectPhotoModel *> * _Nonnull selectPhotoModels) {
            
            [selectPhotos enumerateObjectsUsingBlock:^(UIImage * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                
                
                NSData * data = [ToolClass compressionImageWithImage:obj compressionMaxLimit:COMPRESSIONMAXLIMIT];
                NetWorkUploadFileModel *model = [NetWorkUploadFileModel new];
                model.FILE_NAME = [NSString stringWithFormat:@"%@.jpg",[NSDate getCurrentDate]];
                model.FILE_INDEX = [NSString stringWithFormat:@"%ld",(unsigned long)idx];
                model.FILE_PATH = data;
                model.NAME = @"IMG_URL";
                [weakSelf.imageArray addObject:model];
            }];
            _index = self.imageArray.count;
            [weakSelf.potoView updateUI_PotoArray:weakSelf.imageArray];
            weakSelf.potoView.sd_layout
            .topSpaceToView(self.returnButtonView, ItemHeight * 32)
            .leftSpaceToView(self.backScrollView, 0)
            .rightSpaceToView(self.backScrollView, 0)
            .heightIs(self.potoView.height);
            [weakSelf.potoView updateLayout];
            
        }];
    }
    
}

- (void)ZJSIPotoViewDelegate_deletePotoClick_index:(NSInteger)index{
    _deleImageIndex = index;
    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"是否确定删除图片" message:nil preferredStyle:UIAlertControllerStyleAlert];
    [alertController addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self.imageArray removeObjectAtIndex:_deleImageIndex];
        _index = self.imageArray.count;
        [self.potoView updateUI_PotoArray:self.imageArray];
        self.potoView.sd_layout
        .topSpaceToView(self.returnButtonView, ItemHeight * 32)
        .leftSpaceToView(self.backScrollView, 0)
        .rightSpaceToView(self.backScrollView, 0)
        .heightIs(self.potoView.height);
        [self.potoView updateLayout];
        
    }]];
    [alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
    }]];
    [self presentViewController:alertController animated:YES completion:nil];
    
}

- (void)ZJSIPotoViewDelegate_potoImageClick_index:(NSInteger)index{
    __block NSMutableArray *imageDataArray = [NSMutableArray array];
    [self.imageArray enumerateObjectsUsingBlock:^(NetWorkUploadFileModel *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSDictionary *dict = @{@"image":[UIImage imageWithData:obj.FILE_PATH]};
        [imageDataArray addObject:dict];
    }];
    STPhotoBroswer *view = [[STPhotoBroswer alloc]initWithFrame:CGRectMake(0, 0,self.view.width , self.view.height) ImageArray:imageDataArray currentIndex:index];
    [view show];
}



- (UIScrollView *)backScrollView{
    if (!_backScrollView ) {
        _backScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0 , navHeight, [UIScreen zj_screenWith], [UIScreen zj_screenHeight] - navHeight)];
        _backScrollView.showsVerticalScrollIndicator = NO;
        _backScrollView.showsHorizontalScrollIndicator = NO;
        _backScrollView.contentSize = _backScrollView.size;
        _backScrollView.backgroundColor = [UIColor whiteColor];
    }
    return _backScrollView;
    
}


-(YBNormalWaterLayoutView *)selectView
{
    if (!_selectView) {
        _selectView = [[YBNormalWaterLayoutView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], ItemHeight * 450) title:@"发布对象(0):"];
        [_selectView.selectButton addTarget:self action:@selector(option_selectButton:) forControlEvents:UIControlEventTouchUpInside];
        _selectView.delegate = self;
    }
    return _selectView;
}


- (LPChooseYearAndMonthAndDayAndHourAndMinuteView *)pickTime{
    if (!_pickTime) {
        _pickTime  = [[LPChooseYearAndMonthAndDayAndHourAndMinuteView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
        _pickTime.delegate = self;
    }
    return _pickTime;
}


- (ZJSIPotoView *)potoView{
    if (_potoView == nil){
        _potoView = [[ZJSIPotoView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, 195  * [UIScreen zj_screenHScale]) title:@"上传图片(不得上传任何涉密图片):"];
        [_potoView updateUI_PotoArray:nil];
        _potoView.deletate = self;
        
    }
    return _potoView;
}


-(NSMutableArray *)imageArray
{
    if (!_imageArray) {
        _imageArray = [NSMutableArray array];
    }
    return _imageArray;
}


- (ZJRBTextFliedView *)nameTextField{
    if (_nameTextField == nil){
        _nameTextField = [[ZJRBTextFliedView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 90 * [UIScreen zj_screenHScale]) title:@"会议活动名称:"];
        _nameTextField.maxNumber = 50;
        _nameTextField.textField.placeholder = @"";
        _nameTextField.titleLabel.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _nameTextField.titleLabel.y, self.view.width - 30 * [UIScreen zj_screenWScale], _nameTextField.titleLabel.height);
        _nameTextField.textField.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _nameTextField.textField.y, self.view.width - 30 * [UIScreen zj_screenWScale], _nameTextField.textField.height);
    }
    return _nameTextField;
}

- (MyICRemarkView *)contentTextView{
    if (_contentTextView == nil){
        _contentTextView = [[MyICRemarkView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith],195  * [UIScreen zj_screenHScale] ) title:@"会议内容:"];
        _contentTextView.textView.sd_layout.leftSpaceToView(_contentTextView, ItemWidth * 30 + 1).rightSpaceToView(_contentTextView , ItemWidth * 30 + 1).topSpaceToView(_contentTextView , ItemHeight * 80 + 1).bottomSpaceToView(_contentTextView , ItemHeight * 12 + 1);
        _contentTextView.maxNumber = 200;
        _contentTextView.textView.xx_placeholder = @"";
    }
    return _contentTextView;
}

- (ZJRBTextFliedView *)contactTextField{
    if (_contactTextField == nil){
        _contactTextField = [[ZJRBTextFliedView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 90 * [UIScreen zj_screenHScale]) title:@"联系人:"];
        _contactTextField.maxNumber = 50;
        _contactTextField.textField.placeholder = @"";
        _contactTextField.titleLabel.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _contactTextField.titleLabel.y, self.view.width - 30 * [UIScreen zj_screenWScale], _contactTextField.titleLabel.height);
        _contactTextField.textField.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _contactTextField.textField.y, self.view.width - 30 * [UIScreen zj_screenWScale], _contactTextField.textField.height);
    }
    return _contactTextField;
}

- (ZJRBTextFliedView *)phoneTextField{
    if (_phoneTextField == nil){
        _phoneTextField = [[ZJRBTextFliedView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 90 * [UIScreen zj_screenHScale]) title:@"联系电话:"];
        _phoneTextField.maxNumber = 11;
        _phoneTextField.textField.placeholder = @"";
        _phoneTextField.textField.keyboardType = UIKeyboardTypePhonePad;
        _phoneTextField.titleLabel.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _phoneTextField.titleLabel.y, self.view.width - 30 * [UIScreen zj_screenWScale], _phoneTextField.titleLabel.height);
        _phoneTextField.textField.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _phoneTextField.textField.y, self.view.width - 30 * [UIScreen zj_screenWScale], _phoneTextField.textField.height);
    }
    return _phoneTextField;
}


- (ZJRBTextFliedView *)deptTextField{
    if (_deptTextField == nil){
        _deptTextField = [[ZJRBTextFliedView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 90 * [UIScreen zj_screenHScale]) title:@"发布单位:"];
        _deptTextField.maxNumber = 50;
        _deptTextField.textField.placeholder = @"";
        _deptTextField.textField.text = ZJUSERINFORMODEL.CURRENT_DEPT_MODEL.F_DEPT_NAME;
        _deptTextField.titleLabel.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _deptTextField.titleLabel.y, self.view.width - 30 * [UIScreen zj_screenWScale], _deptTextField.titleLabel.height);
        _deptTextField.textField.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _deptTextField.textField.y, self.view.width - 30 * [UIScreen zj_screenWScale], _deptTextField.textField.height);
    }
    return _deptTextField;
}

- (LPCostomLabelAndTextFieldAndImageView *)meetingTimeTextField{
    if (!_meetingTimeTextField) {
        _meetingTimeTextField = [[LPCostomLabelAndTextFieldAndImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 90 * [UIScreen zj_screenHScale]) title:@"会议时间:" placehold:@"" imageString:@"calendar"];
        _meetingTimeTextField.tag = 15000;
        _meetingTimeTextField.delegate = self;
        _meetingTimeTextField.isShow = YES;
        
    }
    return _meetingTimeTextField;
}

- (LPCostomLabelAndTextFieldAndImageView *)releaseTimeTextField{
    if (!_releaseTimeTextField) {
        _releaseTimeTextField = [[LPCostomLabelAndTextFieldAndImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 90 * [UIScreen zj_screenHScale]) title:@"发布时间:" placehold:@"" imageString:@"calendar"];
        _releaseTimeTextField.tag = 15001;
        _releaseTimeTextField.delegate = self;
        _releaseTimeTextField.isShow = YES;
        
    }
    return _releaseTimeTextField;
}

- (ZJRBTextFliedView *)addressTextField{
    if (_addressTextField == nil){
        _addressTextField = [[ZJRBTextFliedView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen zj_screenWith], 90 * [UIScreen zj_screenHScale]) title:@"会议地址:"];
        _addressTextField.maxNumber = 50;
        _addressTextField.textField.placeholder = @"";
        _addressTextField.titleLabel.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _addressTextField.titleLabel.y, self.view.width - 30 * [UIScreen zj_screenWScale], _addressTextField.titleLabel.height);
        _addressTextField.textField.frame = CGRectMake(15 * [UIScreen zj_screenWScale], _addressTextField.textField.y, self.view.width - 30 * [UIScreen zj_screenWScale], _addressTextField.textField.height);
    }
    return _addressTextField;
}


- (LPCostomLabelAndTextFieldAndImageView *)endTimeTextField{
    if (!_endTimeTextField) {
        _endTimeTextField = [[LPCostomLabelAndTextFieldAndImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 90 * [UIScreen zj_screenHScale]) title:@"截止时间:" placehold:@"" imageString:@"calendar"];
        _endTimeTextField.tag = 15002;
        _endTimeTextField.delegate = self;
        _endTimeTextField.isShow = YES;
        
    }
    return _endTimeTextField;
}


-(UIButton *)addReturnButton
{
    if (!_addReturnButton) {
        _addReturnButton = [ToolClass createButtonWithFrame:CGRectMake(ItemWidth * 50, ItemHeight * 60, ([UIScreen zj_screenWith] - ItemWidth * 100) * 0.55, ItemHeight * 100) text:@"添加报名回执内容" textColor:[UIColor whiteColor] imageName:@"add_people" font:18 imageSize:ItemWidth * 42];
        _addReturnButton.backgroundColor = [UIColor themeColor];
        _addReturnButton.clipsToBounds = YES;
        _addReturnButton.layer.cornerRadius = normalCornerRadius;
        [_addReturnButton addTarget:self action:@selector(option_addReturnButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _addReturnButton;
}


-(UIButton *)previewReturnButton
{
    if (!_previewReturnButton) {
        _previewReturnButton = [ToolClass createButtonWithFrame:CGRectMake(ItemWidth * 50 + ([UIScreen zj_screenWith] - ItemWidth * 100) * 0.6, ItemHeight * 60, ([UIScreen zj_screenWith] - ItemWidth * 100) * 0.4, ItemHeight * 100) text:@"报名回执预览" textColor:[UIColor textBlackColor] imageName:@"" font:18];
        _previewReturnButton.layer.borderColor = [UIColor textBlackColor].CGColor;
        _previewReturnButton.layer.borderWidth = normalBorderWidth;
        _previewReturnButton.backgroundColor = [UIColor whiteColor];
        _previewReturnButton.clipsToBounds = YES;
        _previewReturnButton.layer.cornerRadius = normalCornerRadius;
        [_previewReturnButton addTarget:self action:@selector(option_previewReturnButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _previewReturnButton;
}

-(UIButton *)previewMeetingButton
{
    if (!_previewMeetingButton) {
        _previewMeetingButton = [ToolClass createButtonWithFrame:CGRectMake(ItemWidth * 50, 0, ([UIScreen zj_screenWith] - ItemWidth * 100) * 0.45, ItemHeight * 100) text:@"预览" textColor:[UIColor whiteColor] imageName:@"" font:18];
        _previewMeetingButton.backgroundColor = [UIColor themeColor];
        _previewMeetingButton.clipsToBounds = YES;
        _previewMeetingButton.layer.cornerRadius = normalCornerRadius;
        [_previewMeetingButton addTarget:self action:@selector(option_previewMeetingButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _previewMeetingButton;
}

-(UIButton *)releaseMeetingButton
{
    if (!_releaseMeetingButton) {
        _releaseMeetingButton = [ToolClass createButtonWithFrame:CGRectMake(ItemWidth * 50 + ([UIScreen zj_screenWith] - ItemWidth * 100) * 0.55, 0, ([UIScreen zj_screenWith] - ItemWidth * 100) * 0.45, ItemHeight * 100) text:@"发布" textColor:[UIColor whiteColor] imageName:@"" font:18];
        _releaseMeetingButton.backgroundColor = [UIColor themeColor];
        _releaseMeetingButton.clipsToBounds = YES;
        _releaseMeetingButton.layer.cornerRadius = normalCornerRadius;
        [_releaseMeetingButton addTarget:self action:@selector(option_releaseMeetingButton:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _releaseMeetingButton;
}


-(ZJSqlit *)mySqlite
{
    if (!_mySqlite) {
        _mySqlite = [[ZJSqlit alloc]init];
    }
    return _mySqlite;
}


@end
